import 'package:flutter/material.dart';
import 'package:yuque/app_theme.dart';
import 'package:yuque/widgets/action_item.dart';

class MePage extends StatefulWidget {
  const MePage({Key? key}) : super(key: key);

  @override
  State<MePage> createState() => _MePageState();
}

class _MePageState extends State<MePage> {
  late ScrollController scrollController;

  @override
  void initState() {
    super.initState();
    scrollController = ScrollController();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(top: kToolbarHeight),
      height: double.infinity,
      decoration: BoxDecoration(
        gradient: LinearGradient(
          begin: Alignment.topRight,
          end: Alignment.bottomLeft,
          colors: [Colors.blue.withOpacity(0.2), Colors.transparent],
          stops: [0.01,0.3],
        )
      ),
      child: ListView(
        children: [
          Padding(
            padding: EdgeInsets.symmetric(horizontal: 12),
            child: ClipRRect(
              borderRadius: BorderRadius.circular(5),
              child: ActionItem(
                leading: Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 3.0),
                      child: CircleAvatar(
                        radius: 25,
                        foregroundColor: Colors.transparent,
                        backgroundImage: NetworkImage(
                            "https://cdn.nlark.com/yuque/0/2020/jpeg/anonymous/1593151050959-b3cb1592-b354-4bd2-a5e6-c5967afa5e56.jpeg?x-oss-process=image%2Fresize%2Cm_fill%2Cw_48%2Ch_48%2Fformat%2Cpng"),
                      ),
                    ),
                    Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          "阿里爸爸",
                          style: TextStyle(
                            fontSize: 18,
                            color: AppTheme.darkerText,
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                        SizedBox(height: 5),
                        Text(
                          "阿里爸爸",
                          style: TextStyle(
                            color: AppTheme.deactivatedText,
                            fontSize: 14,
                          ),
                        ),
                        SizedBox(height: 15),
                        SizedBox(
                          height: 30,
                          child: Row(
                            children: <Widget>[
                              RichText(
                                text: TextSpan(
                                    style: TextStyle(
                                      color: AppTheme.darkText,
                                    ),
                                    children: [
                                      TextSpan(text: "0", style: TextStyle(color: AppTheme.darkerText)),
                                      WidgetSpan(child: SizedBox(width: 2)),
                                      TextSpan(
                                          text: "关注",
                                          style: TextStyle(
                                            color: AppTheme.deactivatedText,
                                            fontSize: 13,
                                          )),
                                    ]),
                              ),
                              VerticalDivider(
                                color: AppTheme.grey,
                                indent: 8,
                                endIndent: 8,
                              ),
                              RichText(
                                text: TextSpan(
                                    style: TextStyle(
                                      color: AppTheme.darkText,
                                    ),
                                    children: [
                                      TextSpan(text: "0", style: TextStyle(color: AppTheme.darkerText)),
                                      WidgetSpan(child: SizedBox(width: 2)),
                                      TextSpan(
                                          text: "粉丝",
                                          style: TextStyle(
                                            color: AppTheme.deactivatedText,
                                            fontSize: 13,
                                          )),
                                    ]),
                              ),
                            ],
                          ),
                        ),
                      ],
                    )
                  ],
                ),
                onTap: () {},
              ),
            ),
          ),
          Padding(
            padding: EdgeInsets.all(12),
            child: ClipRRect(
              borderRadius: BorderRadius.circular(8),
              child: Container(
                color: Colors.white,
                padding: EdgeInsets.symmetric(horizontal: 4.0),
                child: Column(
                  children: [
                    ActionItem(
                      leading: Text("收藏", style: TextStyle(fontSize: 16)),
                      onTap: () {},
                    ),
                    Divider(
                      indent: 12,
                      endIndent: 12,
                      height: 1,
                      color: AppTheme.whiteGrey,
                    ),
                    ActionItem(
                      leading: Text("回收站", style: TextStyle(fontSize: 16)),
                      onTap: () {},
                    )
                  ],
                ),
              ),
            ),
          ),
          Padding(
            padding: EdgeInsets.all(12),
            child: ClipRRect(
              borderRadius: BorderRadius.circular(8),
              child: Container(
                color: Colors.white,
                padding: EdgeInsets.symmetric(horizontal: 4.0),
                child: Column(
                  children: [
                    ActionItem(
                      leading: Text("设置", style: TextStyle(fontSize: 16)),
                      onTap: () {},
                    ),
                    Divider(
                      indent: 12,
                      endIndent: 12,
                      height: 1,
                      color: AppTheme.whiteGrey,
                    ),
                    ActionItem(
                      leading: Text("反馈与帮助", style: TextStyle(fontSize: 16)),
                      onTap: () {},
                    ),
                    Divider(
                      indent: 12,
                      endIndent: 12,
                      height: 1,
                      color: AppTheme.whiteGrey,
                    ),
                    ActionItem(
                      leading: Text("关于语雀", style: TextStyle(fontSize: 16)),
                      onTap: () {},
                    ),
                    Divider(
                      indent: 12,
                      endIndent: 12,
                      height: 1,
                      color: AppTheme.whiteGrey,
                    ),
                    ActionItem(
                      leading: Text("活动福利", style: TextStyle(fontSize: 16)),
                      tailDescription: "邀请新用户，赠语雀会员",
                      onTap: () {},
                    ),
                  ],
                ),
              ),
            ),
          ),
          Padding(
            padding: EdgeInsets.all(12),
            child: ClipRRect(
              borderRadius: BorderRadius.circular(8),
              child: Container(
                color: Colors.white,
                padding: EdgeInsets.symmetric(horizontal: 4.0),
                child: Column(
                  children: [
                    ActionItem(
                      leading: Text("空间切换", style: TextStyle(fontSize: 16)),
                      onTap: () {},
                    ),
                  ],
                ),
              ),
            ),
          ),
          GestureDetector(
            onTap: () {},
            child: Container(
              margin: EdgeInsets.all(12),
              width: double.infinity,
              height: 50,
              alignment: Alignment.center,
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(8),
              ),
              child: Text("退出登录", style: TextStyle(fontSize: 16)),
            ),
          ),
        ],
      ),
    );
  }
}
